<html>
<?php session_start();   ?>
		<head>
		</head>


<?php


class Branch {

	public $left = null;
	public $right = null;
	function __construct($num) {
		$this->value = $num;
	}

	public function right() {
		return $this->right;
	}

	public function left() {
		return $this->left;
	}

	public function setRight($branch) {
		$this->right = $branch;
	}

	public function setLeft($branch) {
		$this->left = $branch;

	}

}

class Tree {

	function __construct($rootbranch) {
		$this->root = $rootbranch;
	}


	public function add($num) {
		$branch = new Branch($num);
		$current = '';

		$current = $this->root;

		while(true) {

			if($num < $current->value) {

				if($current->left === null) {
					$current->left = $branch;
					break;
				} else {
                    $current = $current->left;
               	}

			} else if ($num > $current->value) {

				if($current->right === null) {
					$current->right = $branch;
					break;
				} else {
                    $current = $current->left;
               	}

			}

		}
		
	}
}




?>



<body>





</body>


</html>